package org.bozo.im.service.protocols.xmpp.stanza.processor.sasl;

import java.io.IOException;

import org.bozo.im.service.protocols.xmpp.XMPPSession;
import org.bozo.im.service.protocols.xmpp.stanza.Stanza;
import org.bozo.im.service.protocols.xmpp.stanza.processor.StanzaProcessor;
import org.bozo.im.service.protocols.xmpp.stanza.task.sasl.AuthTask;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class MechanismsStanzaProcessor extends StanzaProcessor {

	private static MechanismsStanzaProcessor mInstance;

	private MechanismsStanzaProcessor() {}

	public static MechanismsStanzaProcessor getInstance() {
		if (mInstance == null)
			mInstance = new MechanismsStanzaProcessor();
		return mInstance;
	}

	@Override
	public Stanza getStanza() {
		return Stanza.SASL_MECHANISMS;
	}

	@Override
	public void processStanza(XmlPullParser pParser, XMPPSession pSession, StanzaProcessor pParentProcessor) throws XmlPullParserException, IOException {

		super.processStanza(pParser, pSession, pParentProcessor);
		pSession.getTaskProcessor().pushTask(new AuthTask("0"));
	}
}
